import { ApiProperty, ApiPropertyOptional, OmitType, PartialType } from '@nestjs/swagger';
import {
  IsArray,
  IsEnum,
  IsNotEmpty,
  IsOptional,
  IsString,
} from 'class-validator';
import { BooleanNumber } from "common/utils/data";
import { BasePageDto } from "@/common/base/base.dto";

export class AdminCreateDto{
  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  username: string;

  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  password: string;

  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  name: string;

  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  mobile: string;

  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  job: string;

  @IsNotEmpty()
  @ApiProperty()
  @IsArray()
  roleUuids: string[];
}

export class AdminUpdateDto extends OmitType(PartialType(AdminCreateDto), ['username']){
  @IsOptional()
  @ApiPropertyOptional()
  @IsEnum(BooleanNumber)
  status?: BooleanNumber;
}

export class AdminUpdateMinePasswordDto{
  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  password: string;

  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  oldPassword: string;
}

export class AdminIndexDto extends BasePageDto{
  @IsOptional()
  @ApiPropertyOptional()
  @IsEnum(BooleanNumber)
  status?: BooleanNumber;
}

export class AdminLoginDto {
  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  username: string;

  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  password: string;
}

